home *** CD-ROM | disk | FTP | other *** search
- #include <WM.h>
- #include <MyStructs.h>
- #include <IText.h>
-
- extern SHORT gwidth,gheight,gtop;
-
- VOID OpenF()
- {
- ft.FrontPen=aText->FrontPen;
- ft.BackPen=aText->BackPen;
- ft.DrawMode=aText->DrawMode;
- ft.LeftEdge=aText->LeftEdge;
- ft.TopEdge=aText->TopEdge;
- if(areq)
- {
- if(areq->Type==1)
- {
- ft.LeftEdge+=4;
- ft.TopEdge+=11;
- }
- if(areq->Type==2) ft.TopEdge -= 6;
- }
- i=0;
- if(aText->Font==2) i++;
- ft.ITextFont=&TOPAZ[(i*16)+aText->Style];
- ft.IText=aText->IText;
- ft.NextText=NULL;
- PrintIText(rp,&ft,0,0);
- }
- USHORT DefText(UBYTE m)
- {
- USHORT quit=1,TOK=0,PCode=0;
- ScreenToFront(WMsc);
- Tnr=0;
- HolText(m);
- IWindow.Screen=WMsc;
- if(!(Iwin=(struct Window *)OpenWindow(&IWindow))) return(1);
- Irp=Iwin->RPort;
- WinBorder(Iwin);
- PrintIText(Irp,&ITText[7],0,0);
- SetFont(Irp,StdFont);
- SetTWert();
- SetTDefines();
- do
- {
- Wait(1L << Iwin->UserPort->mp_SigBit);
- while(Wmsg=(struct IntuiMessage*)GetMsg(Iwin->UserPort))
- {
- HolMsg(Wmsg);
- switch(class)
- {
- case MOUSEMOVE: PCode=1;
- break;
- case GADGETUP:
- switch(Id)
- {
- case 0: quit=TOK;
- SaveOk=1;
- break;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10: if(firstT) Retten(m);
- ok=1;
- helpT=firstT;
- if(helpT)
- {
- for(i=0; i<Tnr; i++)
- helpT=helpT->NextText;
- }
- i=1;
- while(ok)
- {
- if(i == Id || helpT==NULL)
- {
- ok=0;
- aText=helpT;
- if(helpT==NULL)
- {
- if(NewText())
- {
- Error(0,0,1);
- break;
- }
- else
- {
- Tanz++;
- if((Tnr+9)<Tanz) Tnr++;
- SetTWert();
- }
- }
- SetTDefines();
- }
- else
- {
- helpT=helpT->NextText;
- i++;
- }
- }
- SetT(m);
- TOK=2;
- break;
- case 11: front=FRONTInfo.LongInt;
- break;
- case 12: back=BACKInfo.LongInt;
- break;
- case 13: left=LEFTInfo.LongInt;
- break;
- case 14: top=TOPInfo.LongInt;
- break;
- /* OK */
- case 25: if(firstT==NULL)
- {
- if(NewText())
- {
- Error(0,0,1);
- break;
- }
- Tanz++;
- if((Tnr+9)<Tanz) Tnr++;
- SetT(m);
- SetTWert();
- }
- Retten(m);
- SetTDefines();
- TOK=2;
- break;
- case 26: break;
- } /* switch Id */
- break;
- case GADGETDOWN:
- switch(Id)
- {
- case 30: PCode=2;
- break;
- case 31: PCode=3;
- break;
- case 32: PCode=1;
- break;
- }
- if(areq==NULL || (areq != NULL && areq->Type < 2))
- {
- switch(Id)
- {
- /* DrawMode 1 */
- case 19: if(++d1 == 4) d1=0;
- ITText1[4].IText=TDMode[d1];
- SetStyle();
- break;
- /* DrawMode 2 */
- case 20: if(++d2 == 4) d2=0;
- ITText1[5].IText=TDMode[d2];
- SetStyle();
- break;
- /* Style */
- case 21:
- case 22:
- case 23:
- case 24: Id-=21;
- stil[Id]++;
- if(stil[Id] == 5) stil[Id]=0;
- ITText1[Id].IText=TStyle[stil[Id]];
- SetStyle();
- break;
- /* Font */
- case 15: if(++f1 == 3) f1=0;
- ITText1[6].IText=FONT[f1];
- RefreshGList(&ITFont,Iwin,NULL,1);
- TxW=8;
- if(f2==2) TxW=10;
- break;
- }
- }
- break;
- }/* switch class */
- if(PCode==1)
- {
- i=Tnr;
- if(Tanz > 9)
- {
- Tnr=((ReglerInfo.VertPot+1)*(Tanz-9)/65535);
- if(i != Tnr) ShowText();
- }
- PCode=0;
- }
- if(PCode > 1)
- {
- while(class != GADGETUP)
- {
- if(PCode==2)
- {
- if(Tnr)
- {
- Tnr--;
- SetTWert();
- }
- }
- else
- {
- if((Tnr+9)<Tanz)
- {
- Tnr++;
- SetTWert();
- }
- }
- GetMessage(Iwin);
- }
- PCode=0;
- }
- }
- }while(quit==1);
- CloseWindow(Iwin);
- ScreenToFront(sc);
- if(quit && m < 2)
- {
- Work();
- SetNewWin(1);
- Ready();
- }
- return(0);
- }
- VOID SetStyle()
- {
- style=FStyle[stil[0]] | FStyle[stil[1]] | FStyle[stil[2]] | FStyle[stil[3]];
- dm=DMode[d1] | DMode[d2];
- RefreshGList(&ITDMode1,Iwin,NULL,6);
- }
- VOID Retten(UBYTE m)
- {
- if(strlen(TEXTBuff)>0)
- {
- aText->FrontPen=front;
- aText->BackPen=back;
- aText->DrawMode=dm;
- aText->Style=style;
- aText->Font=f1;
- aText->LeftEdge=left;
- aText->TopEdge=top;
- strcpy(aText->IText,TEXTBuff);
- if(areq)
- {
- if(areq->Type==2)
- {
- aText->FrontPen=3;
- aText->BackPen=0;
- }
- if(areq->Type==1 && m==1)
- {
- gwidth=8;
- gheight=14;
- gtop=-20;
- if(firstT->Font==2)
- {
- gheight=15;
- gwidth=10;
- gtop=-21;
- }
- gwidth = (strlen(TEXTBuff)*gwidth)+12;
- BType=0;
- abor=agad->GadgetBorder;
- TestBorder();
- agad->Width=gwidth;
- agad->Height=gheight;
- agad->TopEdge=gtop;
- agad->PFlags=1;
- if(agad == awin->FirstGadget)
- agad->LeftEdge = (-31)-gwidth;
- }
- }
- }
- else
- {
- if(Error(36,0,0)){
- if(aText->Parent)
- {
- aText->Parent->NextText=aText->NextText;
- if(aText->NextText)
- {
- helpT=aText->NextText;
- aText->NextText->Parent=aText->Parent;
- }
- else
- {
- helpT=aText->Parent;
- lastT=helpT;
- }
- }
- else
- {
- if(aText->NextText)
- {
- firstT=aText->NextText;
- helpT=firstT;
- helpT->Parent=NULL;
- SetT(m);
- }
- else
- {
- helpT=NULL;
- firstT=NULL;
- SetT(m);
- lastT=NULL;
- if(areq != NULL && areq->Type==1 && m==1)
- {
- if(agad != awin->FirstGadget)
- agad->PFlags=0;
- else
- {
- firstT=aText;
- helpT=aText;
- lastT=aText;
- agad->FirstText=aText;
- m=10;
- }
- }
- }
- }
- if(m < 2) ClrWin();
- if(m != 10)
- {
- FreeMem(aText,sizeof(struct MyText));
- Tanz--;
- if(Tnr > 0 && (Tnr+9) > Tanz) Tnr--;
- }
- aText=helpT;}
- }
- SetTWert();
- }
- VOID SetTWert()
- {
- ShowText();
- SetWert(Tnr,Tanz,Iwin,&Regler,&ReglerInfo);
- }
- VOID SetTDefines()
- {
- TEXTInfo.DispPos=0;
- if(aText)
- {
- strcpy(TEXTBuff,aText->IText);
- top=aText->TopEdge;
- left=aText->LeftEdge;
- back=aText->BackPen;
- front=aText->FrontPen;
- dm=aText->DrawMode;
- style=aText->Style;
- f1=aText->Font;
- }
- if(areq != NULL && areq->Type == 2)
- {
- dm=0;
- f1=0;
- style=0;
- back=0;
- front=3;
- }
- sprintf(TOPBuff,"%d",top);
- sprintf(LEFTBuff,"%d",left);
- sprintf(BACKBuff,"%d",back);
- sprintf(FRONTBuff,"%d",front);
- i=0;
- for(j=1; j<4; j++)
- {
- if((dm & DMode[j]) && i<2) TeilMode();
- }
- while(i<2)
- {
- j=0;
- TeilMode();
- }
- ITText1[6].IText=FONT[f1];
- i=0;
- for(j=1; j<5; j++)
- {
- if(style & FStyle[j]) TeilStyle();
- }
- while(i<4)
- {
- j=0;
- TeilStyle();
- }
- RefreshGadgets(&ITFront,Iwin,NULL);
- ActivateGadget(&EnterText,Iwin,NULL);
- }
- VOID TeilMode()
- {
- ITText1[i+4].IText=TDMode[j];
- if(i) d2=j;
- else d1=j;
- i++;
- }
- VOID TeilStyle()
- {
- ITText1[i].IText=TStyle[j];
- if(i==0) stil[0]=j;
- else if(i==1) stil[1]=j;
- else if(i==2) stil[2]=j;
- else stil[3]=j;
- i++;
- }
- VOID ShowText()
- {
- SetPen(Irp,1,JAM2);
- SetBPen(Irp,2);
- helpT=firstT;
- for(i=0; i<Tnr; i++)
- helpT=helpT->NextText;
- for(i=0; i<10; i++)
- {
- strcpy(LEER,"");
- Move(Irp,389,26+(i*8));
- if(helpT)
- {
- strncpy(LEER,helpT->IText,24);
- helpT=helpT->NextText;
- }
- for(j=strlen(LEER); j<24; j++)
- strcat(LEER," ");
- Text(Irp,LEER,24);
- }
- }
- VOID SetT(UBYTE mode)
- {
- if(mode==0) awin->FirstText=firstT; /* WindowText,ReqText,
- AlertText,SysRequestBodyText */
- if(mode==1) agad->FirstText=firstT; /* GadgetText */
- if(mode==2) aitem->ItemText=firstT; /* ItemText */
- if(mode==3) asub->ItemText=firstT; /* SubItemText */
- if(mode==4) aitem->SelectText=firstT; /* ItemSelectText */
- if(mode==5) asub->SelectText=firstT; /* SubItemSelectText */
- }
- VOID HolText(UBYTE mm)
- {
- if(mm==0) aText=awin->FirstText;
- if(mm==1) aText=agad->FirstText;
- if(mm==2) aText=aitem->ItemText;
- if(mm==3) aText=asub->ItemText;
- if(mm==4) aText=aitem->SelectText;
- if(mm==5) aText=asub->SelectText;
- firstT=aText;
- lastT=aText;
- Tanz=0;
- while(aText)
- {
- lastT=aText;
- Tanz++;
- aText=aText->NextText;
- if(Tanz>9) Tnr++;
- }
- aText=lastT;
- }
- USHORT WriteText(UBYTE m)
- {
- USHORT quit=1;
- strcpy(TEXTBuff,"");
- ScreenToFront(WMsc);
- EWindow.Screen=WMsc;
- if(!(Gwin=(struct Window *)OpenWindow(&EWindow))) return(1);
- Grp=Gwin->RPort;
- WinBorder(Gwin);
- PrintIText(Grp,&ITText1[7],0,0);
- ActivateGadget(&EnterText1,Gwin,NULL);
- HolText(m);
- do
- {
- Wait(1L << Gwin->UserPort->mp_SigBit);
- GetMessage(Gwin);
- if(class==GADGETUP)
- {
- if((Id!=0) && (strlen(TEXTBuff)>0))
- {
- quit=0;
- if(NewText()) Error(0,0,1);
- if(m==0) quit=2;
- }
- else quit=3;
- }
- } while(quit==1);
- CloseWindow(Gwin);
- if(quit==2) PlaceText();
- ScreenToFront(sc);
- return(quit);
- }
- VOID PlaceText()
- {
- SHORT OK=FALSE;
- register int xpo,ypo;
- ModifyIDCMP(awin->win,MOUSEMOVE|MOUSEBUTTONS);
- Wwin=awin->win;
- rp=Wwin->RPort;
- j=aText->DrawMode;
- aText->DrawMode=JAM1|COMPLEMENT;
- ok=0;
- SetAPen(rp,1);
- ActivateWindow(Wwin);
- ScreenToFront(sc);
- do
- {
- Wait(1L << Wwin->UserPort->mp_SigBit);
- while(Wmsg=(struct IntuiMessage*)GetMsg(Wwin->UserPort))
- {
- HolMsg(Wmsg);
- xpo=Wwin->MouseX;
- ypo=Wwin->MouseY;
- switch(class)
- {
- case MOUSEBUTTONS: if(code==SELECTDOWN && ok==1)
- {
- OpenF();
- aText->DrawMode=j;
- OpenF();
- OK=TRUE;
- }
- break;
- case MOUSEMOVE: if((xpo >=0 && ypo >=0) &&
- (xpo <= Wwin->Width &&
- ypo <= Wwin->Height))
- {
- if(ok) OpenF();
- ok=1;
- aText->LeftEdge=xpo;
- aText->TopEdge=ypo;
- OpenF();
- }
- break;
- }
- }
- }while(OK==FALSE);
- ModifyIDCMP(Wwin,NULL);
- ActivateWindow(WMwin);
- if(awin->FirstText==NULL) awin->FirstText=aText;
- }
- USHORT NewText()
- {
- if(aText=(struct MyText *)AllocMem(sizeof(struct MyText),MEMF_CLEAR|MEMF_PUBLIC))
- {
- if(firstT==NULL) firstT=aText;
- aText->Parent=lastT;
- if(lastT) lastT->NextText=aText;
- aText->LeftEdge=left;
- aText->TopEdge=top;
- aText->DrawMode=dm;
- aText->FrontPen=front;
- aText->BackPen=back;
- strcpy(aText->IText,TEXTBuff);
- aText->Font=f1;
- aText->Style=style;
- lastT=aText;
- return(0);
- }
- return(1);
- }
-
-